/******************************************************************************
**                                                                           **
**                 Proprietary and Confidential Information                  **
**                                                                           **
**                 Copyright (c) Conexant Systems, Inc. Unpublished                  **
**                                                                           **
** This source code and the algorithms implemented therein constitute        **
** confidential information and may compromise trade secrets of Conexant Systems,    **
** Inc. or its associates, and any unauthorized use thereof is prohibited.   **
**                                                                           **
******************************************************************************/
#ifndef _container_agent_h_
# define _container_agent_h_

#include "imgbufio.h"
#include "dmbimgio.h"
#include "circbufio.h"
#include "dmbbufio.h"
#include "dc_imgbuf_api.h"
#include "dc_dmbimg_api.h"

typedef enum {
  DBGMON_AGENT_TYPE_CONSUMER = 0, // as a consumer
  DBGMON_AGENT_TYPE_PRODUCER = 1  // as a producer   
} DBGMON_AGENT_TYPE_t;

typedef enum {
  DBGMON_CONTAINER_TYPE_CIRCBUF = 0,  // circbuf
  DBGMON_CONTAINER_TYPE_DMBBUF  = 1,  // dmbbuf
  DBGMON_CONTAINER_TYPE_IMGBUF  = 2,  // imgbuf
  DBGMON_CONTAINER_TYPE_DMBIMG  = 3,  // dmbimg
} DBGMON_CONTAINER_TYPE_t;

typedef struct
{
  union {
    struct
    {
      DC_IMGBUF            *ptrContainer;
      DC_IMGBUF_PRODUCER   *ptrProducer;
      DC_IMGBUF_CONSUMER   *ptrConsumer;
    } imgbuf;

    struct
    {
      DC_CIRCBUF            *ptrContainer;
      DC_CIRCBUF_PRODUCER   *ptrProducer;
      DC_CIRCBUF_CONSUMER   *ptrConsumer;
    } circbuf;

    struct
    {
      DC_DMBBUF            *ptrContainer;
      DC_DMBBUF_PRODUCER   *ptrProducer;
      DC_DMBBUF_CONSUMER   *ptrConsumer;
    } dmbbuf;

    struct
    {
      DC_DMBIMG            *ptrContainer;
      DC_DMBIMG_PRODUCER   *ptrProducer;
      DC_DMBIMG_CONSUMER   *ptrConsumer;
    } dmbimg;

  } a;

  DBGMON_AGENT_TYPE_t isProducer;
  DBGMON_CONTAINER_TYPE_t type;

  IMGBUFIO_t  imgbufio;
  CIRCBUFIO_t circbufio;
  DMBBUFIO_t  dmbbufio;
  DMBIMGIO_t  dmbimgio;

  int state;
  int done;

  UINT32 option_height; // for test of height_specify

  UINT32 nTargetLines;
  UINT32 nProcessLines;
  UINT32 nBytes;

  char *filename;         // output filename for consumer, input filename for producer

  int stride_mode;        // to dump per stride from IMGBUF

  int signature;

  // work storage
  DC_IMAGE_CHANNELS channels;
  DC_IMAGE_BITDEPTH bitdepth;
  DC_IMAGE_FORMAT format;
  void *base;
  UINT32 stride;
  UINT32 ySize;
  UINT32 yStart;
  UINT32 yValue;
  UINT32 width;
  UINT32 height;
  UINT32 unitSizeInBytes;
  UINT32 nUnits;

} Container_Agent_Info;

CPP DBGMON_API int container_agent_init
(Container_Agent_Info *info,
 DBGMON_CONTAINER_TYPE_t c_type,
 DBGMON_AGENT_TYPE_t a_type,
 void *container,
 void *producer_consumer,
 char *filename,
 UINT32 option_height);

CPP DBGMON_API int container_agent_process
(Container_Agent_Info *info);

// for IMGBUF consumer to dump per stride scanlines
CPP DBGMON_API int container_agent_stride_mode_enable
(Container_Agent_Info *info);

CPP DBGMON_API int container_agent_finish
(Container_Agent_Info *info);

CPP DBGMON_API int container_agent_status 
 (Container_Agent_Info *info, 
  int *done, 
  UINT32 *n_lines, 
  UINT32 *n_bytes);

// specify the determined height from inited height of 0
// for imgbuf or dmbimg container..
CPP DBGMON_API int container_agent_height_specify
(Container_Agent_Info *info, UINT32 height);


#endif
